package com.zzb.servlet;

import com.zzb.model.CallUsModel;
import com.zzb.service.CallUsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;

@WebServlet("/callus")
public class CallUsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.处理乱码
        req.setCharacterEncoding(StandardCharsets.UTF_8.toString());
        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());

        //2.得到前端数据

        //3.将数据封装到model


        //4.处理服务逻辑关系
        CallUsService callUsService = new CallUsService();

        //5.得到处理返回值
        List<CallUsModel> callUsModelList = callUsService.getCallUsModelList();
        req.setAttribute("callUsModelList",callUsModelList);

        //6.将数据返回到前端
        req.getRequestDispatcher("/jsp/callus.jsp").forward(req, resp);
    }
}
